package com.zb.zeus.common.core;

import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;

import java.util.Properties;

/**
 * @author fujianjian
 * @since 2021/7/2 12:52
 */
public class ZBApplicationLaunch {

    public static ConfigurableApplicationContext launch(Class source, String... args) {
        SpringApplicationBuilder builder = createSpringApplicationBuilder(source, args);
        return builder.run(args);
    }

    public static SpringApplicationBuilder createSpringApplicationBuilder(Class source, String... args) {
        Properties props = System.getProperties();
        props.setProperty("spring.cloud.bootstrap.name", "application");
        SpringApplicationBuilder builder = new SpringApplicationBuilder(new Class[]{source});
        return builder;
    }
}
